{
  "name": "Case 84 - Startup Funding Tracker",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * 1"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -1088,
        -208
      ],
      "id": "60447402-0a84-467d-8b69-7adc6aabc02c",
      "name": "Weekly Schedule - Monday 9 AM"
    },
    {
      "parameters": {
        "actorId": {
          "__rl": true,
          "value": "buIWk2uOUzTmcLsuB",
          "mode": "list",
          "cachedResultName": "Linkedin Post Search Scraper (No Cookies) (harvestapi/linkedin-post-search)",
          "cachedResultUrl": "https://console.apify.com/actors/buIWk2uOUzTmcLsuB/input"
        },
        "customBody": "{\n  \"authorUrls\": [\n    \"https://www.linkedin.com/company/sequoia-capital\",\n    \"https://www.linkedin.com/company/andreessen-horowitz\",\n    \"https://www.linkedin.com/company/y-combinator\",\n    \"https://www.linkedin.com/company/accel\",\n    \"https://www.linkedin.com/company/greylock-partners\",\n    \"https://www.linkedin.com/company/techcrunch\",\n    \"https://www.linkedin.com/company/venturebeat\"\n  ],\n  \"searchQueries\": [\n    \"raised\",\n    \"funding\",\n    \"Series A\",\n    \"Series B\",\n    \"seed round\",\n    \"closed round\"\n  ],\n  \"maxPosts\": 50,\n  \"scrapeComments\": false,\n  \"scrapeReactions\": false\n}"
      },
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [
        -912,
        -208
      ],
      "id": "c06e025e-1664-4268-8114-bd3434f5316c",
      "name": "Scrape LinkedIn Funding Posts",
      "credentials": {
        "apifyApi": {
          "id": "w5S6YBbbyUddEfQA",
          "name": "Apify account"
        }
      }
    },
    {
      "parameters": {
        "resource": "Datasets",
        "datasetId": "={{ $json.defaultDatasetId }}"
      },
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [
        -736,
        -208
      ],
      "id": "53885250-c592-4b7c-bea8-bb58633fb0d1",
      "name": "Get Dataset Items",
      "credentials": {
        "apifyApi": {
          "id": "w5S6YBbbyUddEfQA",
          "name": "Apify account"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4o-mini"
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "=You are a Startup Funding Announcement Validation Expert.\n\nAnalyze LinkedIn posts to determine if they are genuine startup funding announcements.\n\nReturn ONLY valid JSON in this exact format:\n{\n  \"is_funding_announcement\": \"yes|no\",\n  \"confidence\": 0.95,\n  \"reason\": \"brief explanation\"\n}\n\nCriteria for \"yes\" (genuine funding announcement):\n✅ Announces specific funding round with dollar amount\n✅ \"[Company] raises $X in [round]\" format\n✅ Mentions lead investor and/or participating investors\n✅ Discusses use of funds or growth plans\n✅ Announces round closure (\"closed\", \"secured\", \"raised\")\n✅ Press release or official announcement tone\n✅ Includes funding stage (seed, Series A/B/C, etc.)\n✅ VC firm announcing their investment\n\nCriteria for \"no\" (NOT funding announcement):\n❌ Advice posts about fundraising\n❌ Historical references to past funding\n❌ Fundraising tips or how-to content\n❌ Seeking investment (not announced)\n❌ Job posts at funded companies\n❌ Rumors or speculation about funding\n❌ Funding news aggregation without specifics\n❌ General market commentary on funding trends\n\nRules:\n1. confidence: 0-1 scale (0.9+ for very clear funding announcements)\n2. reason: 1 sentence explaining the decision\n3. Be strict - require actual announced/closed funding rounds\n4. Return ONLY the JSON object, no explanations"
            },
            {
              "content": "=Analyze this LinkedIn post to determine if it's a genuine funding announcement:\n\nAuthor: {{ $json.author.name }}\nPost Date: {{ $json.postedAt.date }}\nPost Content: {{ $json.content }}\n\nReturn only JSON."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        -576,
        -208
      ],
      "id": "321a4f04-86e1-44d8-8321-7c43935b96d1",
      "name": "AI Validation Filter",
      "credentials": {
        "openAiApi": {
          "id": "ICwxUBbatsF2sDvy",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// UNIVERSAL AI RESPONSE PARSER - Same code for ALL cases\nconst items = [];\nconst input = $input.all();\n\nfunction extractJSON(text) {\n  const jsonMatch = text.match(/\\{[\\s\\S]*\\}/);\n  if (!jsonMatch) return null;\n  return jsonMatch[0];\n}\n\ninput.forEach((item, index) => {\n  try {\n    let aiText = item.json.output[0].content[0].text || '';\n    \n    // Clean markdown code blocks\n    aiText = aiText\n      .replace(/```json/gi, '')\n      .replace(/```/g, '')\n      .trim();\n    \n    // Extract JSON object\n    const jsonStr = extractJSON(aiText);\n    \n    if (!jsonStr) {\n      throw new Error('No JSON found in AI response');\n    }\n    \n    // Parse and return clean JSON\n    const parsed = JSON.parse(jsonStr);\n    items.push({ json: parsed });\n    \n  } catch (error) {\n    console.error(`Parse error for item ${index}:`, error.message);\n    // Return empty object on error - no case-specific fields\n    items.push({ json: {} });\n  }\n});\n\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -304,
        -208
      ],
      "id": "f4e9f83f-04e0-4a9c-84d7-c8bee0235a5f",
      "name": "Parse AI Validation"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "is_funding_announcement",
              "name": "is_funding_announcement",
              "value": "={{ $json.is_funding_announcement }}",
              "type": "string"
            },
            {
              "id": "confidence",
              "name": "confidence",
              "value": "={{ $json.confidence }}",
              "type": "number"
            },
            {
              "id": "reason",
              "name": "reason",
              "value": "={{ $json.reason }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -128,
        -208
      ],
      "id": "5bcda616-de02-4a0a-ae18-174ffe12a962",
      "name": "Edit Fields - Validation"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "condition-001",
              "leftValue": "={{ $json.is_funding_announcement }}",
              "rightValue": "yes",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        48,
        -208
      ],
      "id": "24476a81-250f-4cfa-9363-c9d6aff4099c",
      "name": "Filter Only Funding Announcements"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4o-mini"
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "=You are a Startup Funding Intelligence Analyst.\n\nExtract structured funding information from LinkedIn posts.\n\nReturn ONLY valid JSON in this exact format:\n{\n  \"startup_name\": \"Company name that raised funding\",\n  \"funding_amount\": \"$X.XM or $XB (exact amount with currency)\",\n  \"funding_stage\": \"Pre-seed|Seed|Series A|Series B|Series C|Series D+|Bridge|Growth|Not specified\",\n  \"lead_investor\": \"Lead investor name or 'Not specified'\",\n  \"participating_investors\": [\"investor 1\", \"investor 2\", \"investor 3\"],\n  \"industry_sector\": \"SaaS|FinTech|HealthTech|AI/ML|E-commerce|CleanTech|EdTech|Other\",\n  \"use_of_funds\": \"Brief description of how they'll use the money (max 150 chars)\",\n  \"valuation_mentioned\": \"$X valuation if mentioned, otherwise 'Not disclosed'\",\n  \"location\": \"City, Country of startup HQ\",\n  \"opportunity_type\": \"Investment|Job Opportunity|Partnership|Market Research\"\n}\n\nExtraction Rules:\n1. startup_name: Extract exact company name\n2. funding_amount: Include currency symbol and format (e.g., \"$10M\", \"€5.5M\")\n3. funding_stage: Categorize funding round type\n4. lead_investor: Extract lead/anchor investor\n5. participating_investors: Extract all other investors mentioned (up to 5)\n6. industry_sector: Categorize based on company description\n7. use_of_funds: Extract what they plan to do with money (hiring, expansion, product, etc.)\n8. valuation_mentioned: Extract if post mentions valuation\n9. location: Extract startup headquarters location\n10. opportunity_type:\n    - Investment = Early stage, still raising, or interesting opportunity\n    - Job Opportunity = Well-funded, likely hiring\n    - Partnership = Strategic investors, potential partnership\n    - Market Research = Just tracking the space\n\nReturn ONLY the JSON object, no explanations."
            },
            {
              "content": "=Extract funding intelligence from this LinkedIn post:\n\nAuthor: {{ $('Get Dataset Items').item.json.author.name }}\nPost Date: {{ $('Get Dataset Items').item.json.postedAt.date }}\nPost Content: {{ $('Get Dataset Items').item.json.content }}\nEngagement: {{ $('Get Dataset Items').item.json.engagement.likes }} likes, {{ $('Get Dataset Items').item.json.engagement.comments }} comments\n\nReturn only JSON."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        208,
        -208
      ],
      "id": "d766b8bf-4140-4ee6-9317-49cd5dcb7597",
      "name": "AI Extract Funding Intelligence",
      "credentials": {
        "openAiApi": {
          "id": "ICwxUBbatsF2sDvy",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// UNIVERSAL AI RESPONSE PARSER - Same code for ALL cases\nconst items = [];\nconst input = $input.all();\n\nfunction extractJSON(text) {\n  const jsonMatch = text.match(/\\{[\\s\\S]*\\}/);\n  if (!jsonMatch) return null;\n  return jsonMatch[0];\n}\n\ninput.forEach((item, index) => {\n  try {\n    let aiText = item.json.output[0].content[0].text || '';\n    \n    // Clean markdown code blocks\n    aiText = aiText\n      .replace(/```json/gi, '')\n      .replace(/```/g, '')\n      .trim();\n    \n    // Extract JSON object\n    const jsonStr = extractJSON(aiText);\n    \n    if (!jsonStr) {\n      throw new Error('No JSON found in AI response');\n    }\n    \n    // Parse and return clean JSON\n    const parsed = JSON.parse(jsonStr);\n    items.push({ json: parsed });\n    \n  } catch (error) {\n    console.error(`Parse error for item ${index}:`, error.message);\n    // Return empty object on error - no case-specific fields\n    items.push({ json: {} });\n  }\n});\n\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        480,
        -208
      ],
      "id": "9d039a64-67db-47ee-8f7f-8ef6c7535c8c",
      "name": "Parse AI Response"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "timestamp",
              "name": "found_date",
              "value": "={{ new Date().toISOString() }}",
              "type": "string"
            },
            {
              "id": "startup_name",
              "name": "startup_name",
              "value": "={{ $json.startup_name }}",
              "type": "string"
            },
            {
              "id": "funding_amount",
              "name": "funding_amount",
              "value": "={{ $json.funding_amount }}",
              "type": "string"
            },
            {
              "id": "funding_stage",
              "name": "funding_stage",
              "value": "={{ $json.funding_stage }}",
              "type": "string"
            },
            {
              "id": "lead_investor",
              "name": "lead_investor",
              "value": "={{ $json.lead_investor }}",
              "type": "string"
            },
            {
              "id": "participating_investors",
              "name": "participating_investors",
              "value": "={{ $json.participating_investors }}",
              "type": "array"
            },
            {
              "id": "industry_sector",
              "name": "industry_sector",
              "value": "={{ $json.industry_sector }}",
              "type": "string"
            },
            {
              "id": "use_of_funds",
              "name": "use_of_funds",
              "value": "={{ $json.use_of_funds }}",
              "type": "string"
            },
            {
              "id": "valuation",
              "name": "valuation_mentioned",
              "value": "={{ $json.valuation_mentioned }}",
              "type": "string"
            },
            {
              "id": "location",
              "name": "location",
              "value": "={{ $json.location }}",
              "type": "string"
            },
            {
              "id": "opportunity_type",
              "name": "opportunity_type",
              "value": "={{ $json.opportunity_type }}",
              "type": "string"
            },
            {
              "id": "post_content",
              "name": "post_content",
              "value": "={{ $('Get Dataset Items').item.json.content || '' }}",
              "type": "string"
            },
            {
              "id": "post_date",
              "name": "post_date",
              "value": "={{ $('Get Dataset Items').item.json.postedAt?.date || '' }}",
              "type": "string"
            },
            {
              "id": "post_url",
              "name": "post_url",
              "value": "={{ $('Get Dataset Items').item.json.linkedinUrl || '' }}",
              "type": "string"
            },
            {
              "id": "likes",
              "name": "likes_count",
              "value": "={{ $('Get Dataset Items').item.json.engagement?.likes || 0 }}",
              "type": "number"
            },
            {
              "id": "comments",
              "name": "comments_count",
              "value": "={{ $('Get Dataset Items').item.json.engagement?.comments || 0 }}",
              "type": "number"
            },
            {
              "id": "shares",
              "name": "shares_count",
              "value": "={{ $('Get Dataset Items').item.json.engagement?.shares || 0 }}",
              "type": "number"
            },
            {
              "id": "total_engagement",
              "name": "engagement_total",
              "value": "={{ ($('Get Dataset Items').item.json.engagement?.likes || 0) + ($('Get Dataset Items').item.json.engagement?.comments || 0) + ($('Get Dataset Items').item.json.engagement?.shares || 0) }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        640,
        -208
      ],
      "id": "72ca570f-2c81-4a1a-a868-8d34f829bc04",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1p18hGArwLmBW1W7VFOuTmu_WacAuEzmAayOGx7kCNPY",
          "mode": "list",
          "cachedResultName": "Case 84 - Startup funding Log",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1p18hGArwLmBW1W7VFOuTmu_WacAuEzmAayOGx7kCNPY/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1p18hGArwLmBW1W7VFOuTmu_WacAuEzmAayOGx7kCNPY/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Found_Date": "={{ $json.found_date }}",
            "Startup_Name": "={{ $json.startup_name }}",
            "Funding_Amount": "={{ $json.funding_amount }}",
            "Funding_Stage": "={{ $json.funding_stage }}",
            "Lead_Investor": "={{ $json.lead_investor }}",
            "Participating_Investors": "={{ $json.participating_investors.join('; ') }}",
            "Industry_Sector": "={{ $json.industry_sector }}",
            "Use_Of_Funds": "={{ $json.use_of_funds }}",
            "Valuation_Mentioned": "={{ $json.valuation_mentioned }}",
            "Location": "={{ $json.location }}",
            "Opportunity_Type": "={{ $json.opportunity_type }}",
            "Post_Date": "={{ $json.post_date }}",
            "Likes": "={{ $json.likes_count }}",
            "Comments": "={{ $json.comments_count }}",
            "Shares": "={{ $json.shares_count }}",
            "Total_Engagement": "={{ $json.engagement_total }}",
            "Post_URL": "={{ $json.post_url }}",
            "Post_Content": "={{ $json.post_content }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Found_Date",
              "displayName": "Found_Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Startup_Name",
              "displayName": "Startup_Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Funding_Amount",
              "displayName": "Funding_Amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Funding_Stage",
              "displayName": "Funding_Stage",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Lead_Investor",
              "displayName": "Lead_Investor",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Participating_Investors",
              "displayName": "Participating_Investors",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry_Sector",
              "displayName": "Industry_Sector",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Use_Of_Funds",
              "displayName": "Use_Of_Funds",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Valuation_Mentioned",
              "displayName": "Valuation_Mentioned",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Opportunity_Type",
              "displayName": "Opportunity_Type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Post_Date",
              "displayName": "Post_Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Likes",
              "displayName": "Likes",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Comments",
              "displayName": "Comments",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Shares",
              "displayName": "Shares",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Total_Engagement",
              "displayName": "Total_Engagement",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Post_URL",
              "displayName": "Post_URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Post_Content",
              "displayName": "Post_Content",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        800,
        -208
      ],
      "id": "649d6122-1666-425a-a13b-8af5a566525f",
      "name": "Log to Funding Tracker",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "LOs2dbk9lby0NfDM",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Aggregate all items from Google Sheets into email-ready summary\nconst allItems = $input.all();\n\n// Count by funding stage\nconst stageCounts = {};\nallItems.forEach(item => {\n  const stage = item.json.Funding_Stage || 'Unknown';\n  stageCounts[stage] = (stageCounts[stage] || 0) + 1;\n});\n\nconst stageBreakdown = Object.entries(stageCounts)\n  .sort((a, b) => b[1] - a[1]);\n\n// Count by industry sector\nconst sectorCounts = {};\nallItems.forEach(item => {\n  const sector = item.json.Industry_Sector || 'Other';\n  sectorCounts[sector] = (sectorCounts[sector] || 0) + 1;\n});\n\nconst topSectors = Object.entries(sectorCounts)\n  .sort((a, b) => b[1] - a[1]);\n\n// Count by opportunity type\nconst opportunityCounts = {};\nallItems.forEach(item => {\n  const opp = item.json.Opportunity_Type || 'Market Research';\n  opportunityCounts[opp] = (opportunityCounts[opp] || 0) + 1;\n});\n\n// Top investors (lead)\nconst investorCounts = {};\nallItems.forEach(item => {\n  const investor = item.json.Lead_Investor || 'Not specified';\n  if (investor !== 'Not specified') {\n    investorCounts[investor] = (investorCounts[investor] || 0) + 1;\n  }\n});\n\nconst topInvestors = Object.entries(investorCounts)\n  .sort((a, b) => b[1] - a[1])\n  .slice(0, 10);\n\n// Total funding amount (rough estimate - parse amounts)\nlet totalFundingEstimate = 0;\nallItems.forEach(item => {\n  const amount = item.json.Funding_Amount || '';\n  // Extract number from strings like \"$10M\" or \"$5.5B\"\n  const match = amount.match(/\\$([\\d.]+)([MB])?/);\n  if (match) {\n    let value = parseFloat(match[1]);\n    if (match[2] === 'B') value *= 1000; // Convert billions to millions\n    totalFundingEstimate += value;\n  }\n});\n\n// Largest rounds\nconst largestRounds = allItems\n  .map(item => {\n    const amount = item.json.Funding_Amount || '';\n    const match = amount.match(/\\$([\\d.]+)([MB])?/);\n    let value = 0;\n    if (match) {\n      value = parseFloat(match[1]);\n      if (match[2] === 'B') value *= 1000;\n    }\n    return { ...item.json, numericAmount: value };\n  })\n  .sort((a, b) => b.numericAmount - a.numericAmount)\n  .slice(0, 5);\n\n// Build HTML table rows\nconst tableRows = allItems.map(item => {\n  const data = item.json;\n  const oppColor = data.Opportunity_Type === 'Investment' ? '#28a745' : \n                   data.Opportunity_Type === 'Job Opportunity' ? '#17a2b8' : '#6c757d';\n  \n  return `\n    <tr>\n      <td>${data.Startup_Name || 'N/A'}</td>\n      <td>${data.Funding_Amount || 'N/A'}</td>\n      <td>${data.Funding_Stage || 'N/A'}</td>\n      <td>${data.Industry_Sector || 'N/A'}</td>\n      <td><span style=\"color: ${oppColor}; font-weight: bold;\">${data.Opportunity_Type || 'N/A'}</span></td>\n      <td>${data.Lead_Investor || 'N/A'}</td>\n      <td><a href=\"${data.Post_URL || '#'}\">View</a></td>\n    </tr>\n  `;\n}).join('');\n\n// Return single aggregated item\nreturn {\n  json: {\n    week_start: new Date(Date.now() - 7*24*60*60*1000).toISOString().split('T')[0],\n    week_end: new Date().toISOString().split('T')[0],\n    total_announcements: allItems.length,\n    stage_breakdown: stageBreakdown,\n    sector_breakdown: topSectors,\n    opportunity_breakdown: Object.entries(opportunityCounts),\n    top_investors: topInvestors,\n    total_funding_estimate: Math.round(totalFundingEstimate),\n    largest_rounds: largestRounds,\n    table_rows: tableRows,\n    all_funding: allItems.map(item => item.json)\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        976,
        -208
      ],
      "id": "f1ffc552-a4ae-4846-81f6-5d7579d19412",
      "name": "Aggregate Weekly Summary"
    },
    {
      "parameters": {
        "sendTo": "user@email.com",
        "subject": "=💰 Weekly Startup Funding Report: {{ $json.week_start }} to {{ $json.week_end }}",
        "message": "=WEEKLY STARTUP FUNDING INTELLIGENCE REPORT\n================================================\nReport Period: {{ $json.week_start }} to {{ $json.week_end }}\n\nOVERVIEW:\nTotal Funding Announcements: {{ $json.total_announcements }}\nEstimated Total Raised: ~${{ $json.total_funding_estimate }}M\n\nFUNDING STAGE BREAKDOWN:\n{{ $json.stage_breakdown.map(([stage, count]) => stage + ': ' + count + ' rounds').join('\\n') }}\n\nTOP SECTORS:\n{{ $json.sector_breakdown.map(([sector, count]) => sector + ': ' + count + ' companies').join('\\n') }}\n\nOPPORTUNITY TYPE:\n{{ $json.opportunity_breakdown.map(([type, count]) => type + ': ' + count).join('\\n') }}\n\nMOST ACTIVE INVESTORS:\n{{ $json.top_investors.map(([investor, count], i) => (i+1) + '. ' + investor + ' (' + count + ' deals)').join('\\n') }}\n\nLARGEST ROUNDS THIS WEEK:\n{{ $json.largest_rounds.slice(0, 5).map((round, i) => (i+1) + '. ' + round.Startup_Name + ' - ' + round.Funding_Amount + ' (' + round.Funding_Stage + ')').join('\\n') }}\n\nFull funding details in your Google Sheets tracker.\n\nGenerated: {{ new Date().toLocaleDateString() }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1152,
        -208
      ],
      "id": "587e8869-f5ad-4de4-b69b-bc742d73e30a",
      "name": "Send Weekly Summary Email",
      "webhookId": "676d8e43-c37e-4817-a0ad-77d7e8552fdb",
      "credentials": {
        "gmailOAuth2": {
          "id": "cyqCGWcggZNMcSOv",
          "name": "Gmail account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Weekly Schedule - Monday 9 AM": {
      "main": [
        [
          {
            "node": "Scrape LinkedIn Funding Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape LinkedIn Funding Posts": {
      "main": [
        [
          {
            "node": "Get Dataset Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Dataset Items": {
      "main": [
        [
          {
            "node": "AI Validation Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Validation Filter": {
      "main": [
        [
          {
            "node": "Parse AI Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Validation": {
      "main": [
        [
          {
            "node": "Edit Fields - Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields - Validation": {
      "main": [
        [
          {
            "node": "Filter Only Funding Announcements",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Only Funding Announcements": {
      "main": [
        [
          {
            "node": "AI Extract Funding Intelligence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Extract Funding Intelligence": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Log to Funding Tracker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Funding Tracker": {
      "main": [
        [
          {
            "node": "Aggregate Weekly Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Weekly Summary": {
      "main": [
        [
          {
            "node": "Send Weekly Summary Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d2a29ffa-28b5-4b26-a07f-3ca0beb036bc",
  "meta": {
    "instanceId": "3a43da28588548e21903e71cf1dc3ddd65c24bf0c62e7e4b77542ffe87ad79c6"
  },
  "id": "DynPjUrKSVO8HHPf",
  "tags": []
}